home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / • Extras • / SGI STL / pair.h < prev    next >
C/C++ Source or Header  |  1997-05-28  |  3KB  |  83 lines

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Permission to use, copy, modify, distribute and sell this software
  7.  * and its documentation for any purpose is hereby granted without fee,
  8.  * provided that the above copyright notice appear in all copies and
  9.  * that both that copyright notice and this permission notice appear
  10.  * in supporting documentation.  Hewlett-Packard Company makes no
  11.  * representations about the suitability of this software for any
  12.  * purpose.  It is provided "as is" without express or implied warranty.
  13.  *
  14.  *
  15.  * Copyright (c) 1996
  16.  * Silicon Graphics Computer Systems, Inc.
  17.  *
  18.  * Permission to use, copy, modify, distribute and sell this software
  19.  * and its documentation for any purpose is hereby granted without fee,
  20.  * provided that the above copyright notice appear in all copies and
  21.  * that both that copyright notice and this permission notice appear
  22.  * in supporting documentation.  Silicon Graphics makes no
  23.  * representations about the suitability of this software for any
  24.  * purpose.  It is provided "as is" without express or implied warranty.
  25.  *
  26.  * Copyright (c) 1997
  27.  * Moscow Center for SPARC Technology
  28.  *
  29.  * Permission to use, copy, modify, distribute and sell this software
  30.  * and its documentation for any purpose is hereby granted without fee,
  31.  * provided that the above copyright notice appear in all copies and
  32.  * that both that copyright notice and this permission notice appear
  33.  * in supporting documentation.  Moscow Center for SPARC Technology makes no
  34.  * representations about the suitability of this software for any
  35.  * purpose.  It is provided "as is" without express or implied warranty.
  36.  *
  37.  */
  38.  
  39. #ifndef __SGI_STL_PAIR_H
  40. #define __SGI_STL_PAIR_H
  41.  
  42. # ifndef __SGI_STL_BOOL_H
  43. #  include <bool.h>
  44. # endif
  45.  
  46. __BEGIN_STL_NAMESPACE
  47.  
  48. template <class T1, class T2>
  49. struct pair {
  50.     typedef T1 first_type;
  51.     typedef T2 second_type;
  52.  
  53.     T1 first;
  54.     T2 second;
  55. # if defined ( __STL_CONST_CONSTRUCTOR_BUG )
  56.     pair() : first(T1()), second(T2()) {}
  57. # else
  58.     pair() {}
  59. # endif
  60.     pair(const T1& a, const T2& b) : first(a), second(b) {}
  61.     // some compilers need that
  62.     pair(const pair<T1,T2>& o) : first(o.first), second(o.second) {}
  63. };
  64.  
  65. template <class T1, class T2>
  66. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  67.     return x.first == y.first && x.second == y.second; 
  68. }
  69.  
  70. template <class T1, class T2>
  71. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  72.     return (x.first < y.first) || (!(y.first < x.first) && x.second < y.second); 
  73. }
  74.  
  75. template <class T1, class T2>
  76. inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
  77.     return pair<T1, T2>(x, y);
  78. }
  79.  
  80. __END_STL_NAMESPACE
  81.  
  82. #endif
  83.